import request from "@/utils/request.ts";
import Enum from "@/api/consultApi/enum.ts";
import { Image, TopDep, ConsultOrderPreData, ConsultOrderPreParams, PartialConsult, ConsultOrderItem, ConsultOrderListParams, ConsultOrderPage } from "@/types/consultTypes/consultTypes.ts";
import { ResponseType } from "@/types/commonTypes/commonTypes.ts";

/*获取科室列表的接口*/
export const fetchDepartmentAPI = () => request.get<TopDep[], ResponseType<TopDep[]>>(Enum.department);
/*上传文件的接口*/
export const uploadFileAPI = (formData: FormData): Promise<ResponseType<Image>> => request.post<Image, ResponseType<Image>>(Enum.uploadFile, formData);
/*获取订单预支付的接口*/
export const fetchConsultOrderInfoAPI = (params: ConsultOrderPreParams): Promise<ResponseType<ConsultOrderPreData>> => request.get<ConsultOrderPreData, ResponseType<ConsultOrderPreData>, { params: ConsultOrderPreParams }>(Enum.orderInfo, { params });
/*创建订单的接口*/
export const createConsultOrderAPI = (data: PartialConsult): Promise<ResponseType<{ id: string }>> => request.post<{ id: string }, ResponseType<{ id: string }>, PartialConsult>(Enum.createOrder, data);
/*生成支付地址的接口 0是微信  1支付宝*/
export const fetchConsultOrderPayUrlAPI = (params: { paymentMethod: 0 | 1, orderId: string, payCallback: string }): Promise<ResponseType<{ payUrl: string }>> => request.post<{ payUrl: string }, ResponseType<{ payUrl: string }>, {
   paymentMethod: 0 | 1,
   orderId: string,
   payCallback: string
}>(Enum.orderPayUrl, params);
/*获取订单详情的接口*/
export const fetchConsultOrderDetailAPI = (orderId: string): Promise<ResponseType<ConsultOrderItem>> => request.get<ConsultOrderItem, ResponseType<ConsultOrderItem>, { params: { orderId: string } }>(Enum.orderDetail, { params: { orderId } });
/*查看处方的接口*/
export const fetchPrescriptionPicAPI = (id: string): Promise<ResponseType<{ url: string }>> => request.get<{ url: string }, ResponseType<{ url: string }>>(`${Enum.prescriptionPic}/${id}`);
/*获取订单数据的接口*/
export const fetchConsultOrderListAPI = (params: ConsultOrderListParams) => request.get<ConsultOrderPage, ResponseType<ConsultOrderPage>, { params: { params: ConsultOrderListParams } }>(Enum.consultOrderList, { params: params });
/*取消订单的接口*/
export const cancelOrderAPI = (id: string) => request.put(`${Enum.cancelOrder}/${id}`);

/*删除订单的接口*/
export const deleteOrderAPI = (id: string) => request.delete(`${Enum.deleteOrder}/${id}`);


